package com.fr.lintcode;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

import org.junit.Test;

/**
*作者：furong
*日期：2017年3月2日
*时间：下午4:12:52
*/
public class Q131iv {
    public ArrayList<ArrayList<Integer>> buildingOutline(int[][] buildings) {
        ArrayList<ArrayList<Integer>> rs = new ArrayList<>();
        if (buildings == null || buildings.length <= 0) {
            return rs;
        }
        int minLength = Integer.MAX_VALUE;
        int maxLength = 0;
        for (int[] a : buildings) {
            if (a[0] < minLength) {
                minLength = a[0];
            }
            if (a[1] > maxLength) {
                maxLength = a[1];
            }
        }
        return rs;
    }

    @Test
    public void testA() throws IOException {
        // int[][] buildings = { { 1, 3, 3 }, { 2, 4, 4 }, { 5, 6, 1 } };
        // int[][] buildings = { { 1, 10, 3 }, { 2, 5, 8 }, { 7, 9, 8 } };
        File f = new File("C:\\Users\\Hunteron\\Downloads\\17.in");
        FileReader fr = new FileReader(f);
        @SuppressWarnings("resource")
        BufferedReader br = new BufferedReader(fr);
        String line = br.readLine();
        String[] s = line.split("},");
        int[][] buildings = new int[s.length][3];
        for (int i = 0; i < s.length; i++) {
            String n[] = s[i].split(",");
            if (n.length == 3) {
                buildings[i][0] = Integer.parseInt(n[0]);
                buildings[i][1] = Integer.parseInt(n[1]);
                buildings[i][2] = Integer.parseInt(n[2]);
            }
        }
        long begin = System.currentTimeMillis();
        ArrayList<ArrayList<Integer>> rs = buildingOutline(buildings);
        System.out.println(System.currentTimeMillis() - begin);
        System.out.println(rs);
    }

}
